<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<title></title>
		<link href="css/mui.min.css" rel="stylesheet"/>
		<script src="js/mui.min.js"></script>
    	<script src="js/jquery-1.8.2.min.js"></script>
		
	</head>
	<body>
		<!--下拉刷新容器-->
		<ul  id="lis" class="mui-table-view">
		
		</ul>
		<div id="pullrefresh" class="mui-content mui-scroll-wrapper" >
			<div class="mui-scroll">
				<!--数据列表-->
				<ul class="mui-table-view mui-table-view-chevron">
					
				</ul>
			</div>
		</div>
	<script type="text/javascript" charset="UTF-8">
		mui.init({
				pullRefresh: {
					container: '#pullrefresh',
					down: {
						callback: pulldownRefresh
					},
					up: {
						contentrefresh: '正在加载...',
						callback: pullupRefresh
					}
				}
			});
		var $$=jQuery.noConflict();
		/**
			 * 下拉刷新具体业务实现
			 */
			function pulldownRefresh() {
				setTimeout(function() {
					/*console.log("pppppppppp");
					var table = document.body.querySelector('.mui-table-view');
					var cells = document.body.querySelectorAll('.mui-table-view-cell');
					for (var i = cells.length, len = i + 3; i < len; i++) {
						var li = document.createElement('li');
						li.className = 'mui-table-view-cell';
						li.innerHTML = '<a class="mui-navigate-right">Item ' + (i + 1) + '</a>';
						//下拉刷新，新纪录插到最前面；
						table.insertBefore(li, table.firstChild);
					}
					
					mui('#pullrefresh').pullRefresh().endPulldownToRefresh(); //refresh completed*/
				}, 1500);
			};
			var currentPage = 1;
			/**
			 * 上拉加载具体业务实现
			 */
			function pullupRefresh() {
				setTimeout(function() {
					currentPage++;
					var url = 'http://192.168.1.56:8080/Bid/Json/GetProjectList.action';
					var param = {"currentPage":currentPage};
					mui.post(url,param,function(data){
						var jsonData = new Function("return"+data)();
						for(var o in jsonData){
							//mui.toast(jsonData[o].projectId + "==" +jsonData[o].projectName);
							$$("#lis").append("<li onclick='openNew(\""+jsonData[o].projectId+"\",\""+jsonData[o].projectName+"\", \""+ jsonData[o].projectSupplierId+"\" );' class='mui-table-view-cell' ><div class='mui-table'> <div class='mui-table-cell mui-col-xs-10'> <h4 class='mui-ellipsis'>"+jsonData[o].projectName+"</h4><h5>中标单位："+jsonData[o].projectCompName+"</h5></div></div></li>");
						}
						mui('#pullrefresh').pullRefresh().endPullupToRefresh((jsonData.length<8)); //参数为true代表没有更多数据了。
					},"json");
					
					
				}, 1500);
			};
			
			if (mui.os.plus) {
				mui.plusReady(function() {
					setTimeout(function() {
						mui('#pullrefresh').pullRefresh().pullupLoading();
					}, 1000);

				});
			} else {
				mui.ready(function() {
					mui('#pullrefresh').pullRefresh().pullupLoading();
				});
			}	
			
		function openNew(projectId,projectName,supplierId){
			var param = {pId : projectId , name :projectName , supplierId : supplierId};
			mui.openWindow({
			    url: 'info.html', 
			    id:'info.html',
			    extras:param
			  });
		};
		
		
		
		</script>
	</body>
</html>
